/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package seso;

import javax.swing.*;

/**
 *
 * @author Administrator
 */
public class HeaderJSeparator extends JSeparator {

    public JTable jTable;
    public int index;

    public HeaderJSeparator() {
        super();

        setCursor(new java.awt.Cursor(java.awt.Cursor.E_RESIZE_CURSOR));

        addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {

            public void mouseDragged(java.awt.event.MouseEvent evt) {
                evtMouseDragged(evt);
            }
        });
    }

    private void evtMouseDragged(java.awt.event.MouseEvent evt) {
        if ((jTable.getColumnModel().getColumn(index).getWidth() + evt.getX() < 20)
                || (jTable.getColumnModel().getColumn(index).getWidth() + evt.getX() > 1024)) {
            return;
        }

        setLocation(evt.getX() + getX(), getY());
        jTable.getColumnModel().getColumn(index).setPreferredWidth(jTable.getColumnModel().getColumn(index).getWidth() + evt.getX());
    }

    public JTable getJTable() {
        return jTable;
    }

    public void setJTable(JTable jTable) {
        this.jTable = jTable;
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}
